package com.br4mmie.asciistory.map;

import java.util.Random;

/**
 * an encounter to be managed by the map
 * @author Bram Buurlage
 */
public class Encounter 
{
	private String enemtype;
	private double percentage;
	private Random random;
	
	/**
	 * @param enemtype enemytype to refer to
	 * @param percentage chance of an encounter (per moved tile)
	 */
	public Encounter(String enemtype, double percentage)
	{
		this.enemtype = enemtype;
		this.percentage = percentage;
		random = new Random();
	}
	
	/**
	 * returns a filename to an enemy type if there should be something to be encountered
	 * otherwise it returns null
	 * @return obvious.
	 */
	public String encounter()
	{
		if (random.nextDouble()*100.0 < percentage)
		{
			return enemtype;
		}
		return null;
	}
}
